<HTML><HEAD><TITLE>library(dbi)</TITLE></HEAD><BODY>
[ <A HREF="../../index.html">Reference Manual</A> | <A HREF="../../fullindex.html">Alphabetic Index</A> ]<H1>library(dbi)</H1>
Interface to MySQL databases
<H2>Predicates</H2>
<BLOCKQUOTE>
<DL>
<DT><A HREF="cursor_N_execute-4.html"><STRONG>cursor_N_execute(++Cursor, -Executed, +TupleList, -RestTupleList)</STRONG></A></DT>
<DD>Executes the parametrised prepared SQL statement represented by Cursor, once for each tuple in TupleList.</DD>
<DT><A HREF="cursor_N_tuples-4.html"><STRONG>cursor_N_tuples(++Cursor, -Retrieved, -ResultTuples, -RestResultTuples)</STRONG></A></DT>
<DD>Retrieve  result tuples from the SQL query in the difference list ResultTuples and RestResultTuples.</DD>
<DT><A HREF="cursor_all_execute-2.html"><STRONG>cursor_all_execute(++Cursor, +TupleList)</STRONG></A></DT>
<DD>Executes the parametrised prepared SQL statement represented by Cursor, once for each tuple in TupleList.</DD>
<DT><A HREF="cursor_all_tuples-2.html"><STRONG>cursor_all_tuples(++Cursor, -ResultTuples)</STRONG></A></DT>
<DD>Retrieve all remaining result tuples from the SQL query in ResultTuples</DD>
<DT><A HREF="cursor_close-1.html"><STRONG>cursor_close(++Cursor)</STRONG></A></DT>
<DD>Close the cursor associated with Cursor</DD>
<DT><A HREF="cursor_next_execute-2.html"><STRONG>cursor_next_execute(++Cursor, +Tuple)</STRONG></A></DT>
<DD>Executes the parametrised prepared SQL statement represented by Cursor.</DD>
<DT><A HREF="cursor_next_execute-3.html"><STRONG>cursor_next_execute(++Cursor, +Tuple, ++Options)</STRONG></A></DT>
<DD>Executes the parametrised prepared SQL statement represented by Cursor, with options Options.</DD>
<DT><A HREF="cursor_next_tuple-2.html"><STRONG>cursor_next_tuple(++Cursor, -ResultTuple)</STRONG></A></DT>
<DD>Retrieve the next result tuple from the SQL query in ResultTuple</DD>
<DT><A HREF="session_close-1.html"><STRONG>session_close(++Session)</STRONG></A></DT>
<DD>close a session for the DBMS</DD>
<DT><A HREF="session_commit-1.html"><STRONG>session_commit(++Session)</STRONG></A></DT>
<DD>commits transactional changes made to the database.</DD>
<DT><A HREF="session_rollback-1.html"><STRONG>session_rollback(++Session)</STRONG></A></DT>
<DD>rollback transactional changes made to the database.</DD>
<DT><A HREF="session_sql-3.html"><STRONG>session_sql(++Session, ++SQL, -RowProcessedCount)</STRONG></A></DT>
<DD>Executes a SQL statement on the database server.</DD>
<DT><A HREF="session_sql_prepare-4.html"><STRONG>session_sql_prepare(++Session, +ParamTemplate, ++SQL, -Cursor)</STRONG></A></DT>
<DD>Prepares a SQL statement for execution by the DBMS.</DD>
<DT><A HREF="session_sql_prepare_query-5.html"><STRONG>session_sql_prepare_query(++Session, +ParamTemplate, +ResultTemplate, ++SQLQuery, -Cursor)</STRONG></A></DT>
<DD>Prepares a SQL query for execution by the DBMS.</DD>
<DT><A HREF="session_sql_query-4.html"><STRONG>session_sql_query(++Session, +ResultTemplate, ++SQLQuery, -Cursor)</STRONG></A></DT>
<DD>Executes a SQL query on the database server.</DD>
<DT><A HREF="session_sql_query-5.html"><STRONG>session_sql_query(++Session, +ResultTemplate, ++SQLQuery, ++Options, -Cursor)</STRONG></A></DT>
<DD>Executes a SQL query on the database server with options specified by Options.</DD>
<DT><A HREF="session_start-4.html"><STRONG>session_start(++Login, ++Password, ++Options, -Session)</STRONG></A></DT>
<DD>starts a new session for the DBMS</DD>
<DT><A HREF="session_transaction-2.html"><STRONG>session_transaction(++Session, +Goal)</STRONG></A></DT>
<DD>executes Goal as a database transaction.</DD>
<DT><STRONG>session_transaction(?, ?, ?)</STRONG></DT>
<DD>No description available</DD>
</DL>
</BLOCKQUOTE>
<H2>Structures</H2>
<BLOCKQUOTE>
<DL>
<DT><STRONG>struct cursor(handle, session)</STRONG></DT>
<DD>No description available</DD>
</DL>
</BLOCKQUOTE>
<H2>Description</H2>
<P>
 This library provides an interface to database management systems (DBMS)
 that supports SQL (Structure Query Language), allowing SQL commands,
 written in an ECLiPSe program, to be passed to the DBMS for processing,
 and their results (if any) to be passed back to ECLiPSe.
</P><P>
 The exact SQL supported by the library is determined by the underlying
 DBMS, as the SQL commands are passed directly to the DBMS via its C API. 
 If supported by the C API, the library also allows the use of prepared SQL
 statements, where a SQL statement, possibly parameterised to accept
 different input data, is parsed once by the DBMS, and efficiently executed
 multiple times. Support for transactions (with commit and rollback) is also
 provided.
</P><P>
 The library provides a relatively low-level interface to the DBMS, but
 higher level interfaces (e.g. where a SQL query is viewed as a predicate,
 yielding different results tuples on backtracking) can be constructed on
 top of this.
</P><P>
 Currently, MySQL (version 5.0 or later) is supported by the library.
 Note that the MySQL client dynamic library (libmysqlclient.so on Unix
 systems, mysql.dll on Windows) is not included with the distribution, and
 if this file is not found by ECLiPSe on loading lib(dbi), there will be 
 an error. This file can be obtained by downloading MySQL, and placing the
 .so or .dll file into a place where ECLiPSe can find it, for example a 
 standard system library location, or in the ECLiPSe library location 
 (<eclipsedir>/lib/<arch>).
 
</P><P>
 Data is exchanged with the DBMS via:
<DL>
<P>
<DT>SQL statements (input)
  <DD>Directly in the SQL statements passed to the DBMS;
<P>
<DT>SQL query results (output)
  <DD>The results returned by SQL queries are returned to ECLiPSe via
      result tuples. Each tuple represents a single row of result, and is
      returned to ECLiPSe as a Prolog structure, with each argument
      represents one column in the result tuple. The ordering of the
      arguments corresponds to the ordering defined by the SQL query.
<DT>Parameters for prepared SQL statements (input)
  <DD>If prepared statements are supported by the DBMS, data can also be
      passed to the DBMS via parameters (also known as placeholders). Each
      parameter functions like a variable, whose value is instantiated when
      the statement is executed. The library passes parameter values to the
      DBMS via Prolog structures, with each argument represent one parameter. 
      The ordering of the arguments is defined by the ordering of the
      parameters in the prepared SQL statement.
 </DL>
<P>
 Input and output data in the structures need to be converted from/to
 ECLiPSe datatypes. The ECLiPSe datatype is specified by a template, which
 specifies the datatype by example, i.e. an example result tuple structure
 (for output) or parameter structure (for input) where each argument
 specify the type for that argument, e.g.
    <TT>emp(123,"some name",100.0,'some job',extra(data))</TT>,
 specifies that the first argument should be an integer, the second a 
 string, the third a real, the fourth, an atom, and the last, a general
 Prolog term. Note that general Prolog terms are stored in the database in
 a binary representation, and the conversion is done by the library. 
</P><P>
 The data is exchanged with the DBMS via buffers. Some DBMS require the
 sizes of the buffers to be specified. This is done automatically by the
 library, but if the default sizes need to overridden (e.g. if the argument
 is large), the template can be used to specify the size of buffers for
 variable length data, e.g.
    <TT>emp(123,"1000",100.0,'2000',extra(5000))</TT>,
 where the second argument <TT>"1000"</TT> specifies a buffer size of 1000
 bytes, the third argument <TT>'2000'</TT> a buffer size of 2000 bytes,
 and the last argument, <TT>extra(5000)</TT>, a buffer size of 5000 bytes.
 Note that any size specifications are simply ignored if not required.

<H2>About</H2><UL COMPACT>
<LI><STRONG>Author: </STRONG>Kish Shen, based on Oracle interface by Stefano Novello
<LI><STRONG>Copyright &copy; </STRONG>Cisco Systems, 2006
<LI><STRONG>Date: </STRONG>$Date: 2009/02/19 07:23:37 $
</UL>
<HR>Generated from dbi.eci on 2009-05-27 01:25
</BODY></HTML>
